package io.sage.modules.sensor.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import io.sage.modules.sensor.dao.SysSensorConfigurationMapper;
import io.sage.modules.sensor.entity.SysSensorConfiguration;
import io.sage.modules.sensor.service.SensorConfigurationService;

@Service("sensorConfigurationService")
public class SensorConfigurationServiceImpl implements SensorConfigurationService {
	
	@Autowired
	private SysSensorConfigurationMapper sensorConfigurationMapper;

	@Override
	public List<SysSensorConfiguration> selectStudentLists(Map<String, Object> paramMap) {
		
		return sensorConfigurationMapper.selectSensorList(paramMap);
	}

	@Override
	public SysSensorConfiguration selectById(Integer id) {

		return sensorConfigurationMapper.selectByPrimaryKey(id);
	}

	@Override
	public int insert(SysSensorConfiguration sensorConfiguration) {
		
		sensorConfiguration.setCreateTime(new Date());
		sensorConfiguration.setUpdateTime(new Date());
		sensorConfiguration.setDisFlag(1);
		
		return sensorConfigurationMapper.insertSelective(sensorConfiguration);
	}

	@Override
	public int updateAllColumnById(SysSensorConfiguration sensorConfiguration) {
		
		sensorConfiguration.setUpdateTime(new Date());
		
		return sensorConfigurationMapper.updateByPrimaryKeySelective(sensorConfiguration);
	}

	@Override
	public int deleteBatchIds(Integer[] ids) {
	
		return sensorConfigurationMapper.deleteBatchIds(ids);
	}

	@Override
	public int stopOrstart(Integer id, Integer disFlag) {
		
		SysSensorConfiguration sensorConfiguration = new SysSensorConfiguration();
		sensorConfiguration.setId(id);
		sensorConfiguration.setDisFlag(disFlag);
		
		return sensorConfigurationMapper.updateByPrimaryKeySelective(sensorConfiguration);
	}
	
	/**
	 * 根据硬件的查询地址去查找硬件的id
	 * @param querySensor
	 * @return
	 */
	@Override
	public SysSensorConfiguration selectByquerySensor(String querySensor) {
		return sensorConfigurationMapper.selectByquerySensor(querySensor);
	}

}
